package zj.chunan.navigate.action;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import zj.chunan.navigate.model.Navigate;
import zj.chunan.navigate.service.NavigateManager;

 public class NavigateEditAction extends HttpServlet {  
	       
     public void doGet(HttpServletRequest request, HttpServletResponse response)  
             throws ServletException, IOException {  
         this.doPost(request, response);  
     }  
     public void doPost(HttpServletRequest request, HttpServletResponse response)  
             throws ServletException, IOException {  
         String idstr = request.getParameter("id");  
         String parentId = request.getParameter("parentId");  
         String leaf = request.getParameter("leaf");  
         String number = request.getParameter("number");  
         Navigate obj = null;  
         if(null != idstr){  
             NavigateManager navigateManager = new NavigateManager();  
             obj = navigateManager.get(idstr);  
         }else{  
             obj = new Navigate();  
             obj.setParentId(new Integer(parentId));  
             obj.setLeaf(new Integer(leaf));  
             obj.setNumber(new Integer(number));  
         }  
         request.setAttribute("obj", obj);  
         RequestDispatcher dispatcher = request.getRequestDispatcher("/navigate/console-edit.jsp");  
         dispatcher.forward(request, response);  
     }  
 } 
